import instance from '@/util/http'
import { type goodsTypeInfo, type goodsTypeS } from '@/page/types/sale/goodsType'

/**
 * 获取商品类型列表
 * @param data
 */
export const goodsTypesPage = async (data: any) => instance.post('sale/goods/type/page', data)
/**
 * 商品类型下拉框
 * @param name
 */
export const selectGoodsTypes = async (name: string | null) => instance.get('sale/goods/type/select', { name: name })
/**
 * 商品类型添加
 * @param data
 */
export const addGoodsType = async (data: goodsTypeInfo) => instance.post('sale/goods/type/add', data)
/**
 * 商品类型更新
 * @param data
 */
export const updateGoodsType = async (data: goodsTypeInfo) => instance.put('sale/goods/type/update', data)
/**
 *
 * @param id
 */
export const detailGoodsType = async (id: string) => instance.get('sale/goods/type/detail', { id: id })
/**
 *  删除商品类型
 * @param id
 */
export const delGoodsType = async (id: string) => instance.delete('/sale/goods/type/delete/' + id)
/**
 * 商品类型下拉框
 * @param name
 * @returns
 */
export const selectType = async (name: string) => instance.get('/sale/goods/type/select', { name: name })
/**
 * 商品分类下拉框
 * @param name
 * @returns
 */
export const selectSpec = async (name: string) => instance.get('/sale/goods/spec/selectSpec', { name: name })
/**
 * 商品分类详情下拉框
 * @param name
 * @returns
 */
export const selectSpecDetail = async (id: string, name: string) => instance.get('/sale/goods/spec/selectSpecDetail/' + id, { name: name })
/**
 * 商品标签下拉框
 * @param name
 * @returns
 */
export const selectLabel = async (name: string) => instance.get('/sale/goods/label/select', { name: name })
/**
 * 商品品牌下拉框
 * @param name
 * @returns
 */
export const selectBrand = async (name: string) => instance.get('/sale/goods/brand/select', { name: name })
/**
 * 获取商品分页
 * @returns
 */
export const goodsPage = async (data: any) => instance.post('/sale/goods/page', data)
/**
 * 添加商品
 * @param data
 * @returns
 */
export const addGoods = async (data: any) => instance.post('/sale/goods/add', data)
/**
 * 更新商品
 * @param data
 * @returns
 */
export const updateGoods = async (data: any) => instance.put('/sale/goods/update', data)
/**
 * 商品详情
 * @param id
 * @returns
 */
export const detailGoods = async (id: string) => instance.get('/sale/goods/detail/' + id)
/**
 * 添加标签
 * @param label
 * @returns
 */
export const addLabel = async (label: string) => instance.get('/sale/goods/label/save', { name: label })
/**
 * 删除商品
 * @param id
 * @returns
 */
export const delGoods = async (id: string) => instance.delete('/sale/goods/delete/' + id)
/**
 * 添加品牌
 */
export const addGoodsBrand = async (data: any) => instance.post('/sale/goods/brand/add', data)
/**
 * 删除品牌
 */
export const delGoodsBrand = async (id: string) => instance.delete('/sale/goods/brand/delete/' + id)
/**
 * 品牌详情
 */
export const detailGoodsBrand = async (id: string) => instance.get('/sale/goods/brand/detail/' + id)
/**
 * 品牌分页
 */
export const goodsBrandPage = async (data: any) => instance.post('/sale/goods/brand/page', data)
/**
 * 更新品牌
 */
export const updateGoodsBrand = async (data: any) => instance.put('/sale/goods/brand/update', data)
/**
 * 添加商品分类
 * @param data
 * @returns
 */
export const addGoodsSpec = async (data: any) => instance.post('/sale/goods/spec/add', data)
/**
 * 更新商品分类
 * @param data
 * @returns
 */
export const updataGoodsSpec = async (data: any) => instance.put('/sale/goods/spec/update', data)
/**
 * 删除商品分类
 * @param id
 * @returns
 */
export const delGoodsSpec = async (id: string) => instance.delete('/sale/goods/spec/delete/' + id)
/**
 * 添加商品附件
 * @param id
 * @param data
 * @returns
 */
export const addGoodsFile = async (id: string, data: any) => instance.post('/sale/goods/addFile/' + id, data)
/**
 * 得到商品附件
 * @param id
 * @returns
 */
export const getGoodsFile = async (id: string) => instance.get('/sale/goods/getFiles/' + id)

/**
 * 更新商品分类详情
 * @param id
 * @param data
 * @returns
 */
export const editGoodsSpecDetail = async (id: string, data: any) => instance.put('/sale/goods/spec/editDetail/' + id, data)
/**
 * 商品分类详情
 * @param id
 * @returns
 */
export const detailGoodsSpec = async (id: string) => instance.get('/sale/goods/spec/detail/' + id)
/**
 * 商品分类分页
 * @param data
 * @returns
 */
export const pageGoodsSpec = async (data: any) => instance.post('/sale/goods/spec/page', data)
/**
 * 商品分类详情分类列表
 * @param id
 * @returns
 */
export const goodsSpecDetailList = async (id: string) => instance.get('/sale/goods/spec/detailList/' + id)
/**
 * 获取枚举list
 */
export const getEnumList = async (name: string) => instance.get('/sale/enum/getList/' + name)
/**
 * 获取订单分页
 * @param data
 * @returns
 */
export const getOrderPage = async (data: any) => instance.post('/sale/order/page', data)
/**
 * 获取订单详情
 * @param data
 * @returns
 */
export const getOrderInfoByCode = async (code: string) => instance.get('/sale/order/getOrderInfoByCode/' + code)
